<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
    function changstatusPro(t)
    {
        var str = selectallpro();
        if(str !=false)
        {
            if(confirm("确认将选中的订单，修改状态?"))
            {
                $.post("/factory/ajaxbutton", {"op": "changstatus","id":str,"st":t},
                        function(data){
                            if(data==200)
                            {
                                document.location.href = "/factory/orderlist";
                                return;
                            }

                            return;
                        },"json");
            }
        }
    }
    function addPrint() {
        if(confirm("确认打印选中的订单，一旦打印将会自动标注打印标记?")){
        }else{
            return false;
        }
        var obj=document.getElementsByName('ppid[]');
        var chk_value =[];
        var s= "";
        for (var i=0;i<obj.length;i++)
        {
            if(obj[i].checked) s+=obj[i].value+','; //如果选中，将value添加到变量s中
        }
        if(s){
            var url ='/productprint/ajaxbutton?op=orderPrint&param='+s;
            window.open(url);
        }else{
            alert("请选择需要打印的订单!");return ;
        }

    }
    function updfactorystatus(id,status){
        $.post("/productprint/editprintstatus",{id:id,status:status},function(data){
            if(data.code)
            {
                alert(data.msg);
                if(data.code==1){
                    $('#showstatus').html('已完成');
                }else{
                    $('#showstatus').html('已作废');
                }
                location.reload();
            }else{
                alert(data.msg);return false;
            }
        },"json");
    }
    function outExcel() {
        $("#flag_excel").val(1);
        $("#search").submit();
        $("#flag_excel").val(0);
    }
    //批量修改订单状态
    function updOrderStatus(status) {
        var str = selectallpro();
        if(str !=false)
        {
            if (status == 2) {
                var message = "是否确认标完成?";
            } else if (status == 3) {
                var message = "是否确认标作废?";
            }else{
                return false;
            }
            if(confirm(message)){
                $.post("/productprint/editprintstatus", {"id":str,"status":status},
                        function(data){
                            if(data.code==1)
                            {
                                alert(data.msg);
                                location.reload();
                            }else{
                                alert("未知错误");return false;
                            }
                            return false;
                        },"json");

            }else{
                return false;
            }
        }

    }
</script>
<title>印花订单列表</title>
<body class="withvernav">
<div class="bodywrapper">
    {{include file='/public/leftmenu.tpl'}}
    <div class="centercontent">
        <div class="pageheader notab">
            <h1 class="pagetitle">印花订单列表</h1>
            <span class="pagedesc"></span>
            <div class="menulist">
                <ul class="profile_summary">
                    {{if $managers || in_array('112',$showpower)}}  <li> <a href="javascript:void(0);" onclick="javascript:window.open('/productprint/addproductprint')" ><span>添加</span></a></li>{{/if}}
                </ul>
            </div>

        </div>
        <!--pageheader-->
        <div id="contentwrapper" class="contentwrapper">
            <div id="basicform" class="subcontent">
                <!--搜索栏-->
                <div>
                    <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
                </div>
                <form class="stdform stdform2" method="get" id="search" action="/productprint/showlist">
                    <div class="tableoptions">
                        <select name="search_goods" id="search_goods"  class="selection select2_group" style="width:150px;" >
                            <option value="" >查询条件</option>
                            <option value="1" {{if $search_goods eq 1}}selected{{/if}}>商品编号</option>
                            <option value="2" {{if $search_goods eq 2}}selected{{/if}}>创建人</option>
                            <option value="3" {{if $search_goods eq 3}}selected{{/if}}>序号</option>
                        </select>
                        <input type="text" name="goods" id="goods" class="width200" value="{{$goods}}" placeholder="请按照查询条件查询" />
                        <select name="search_status" id="search_status"  class="selection select2_group" style="width:150px;" >
                            <option value="" >状态</option>
                            <option value="1" {{if $search_status eq 1}}selected{{/if}}>生产中</option>
                            <option value="2" {{if $search_status eq 2}}selected{{/if}}>完成</option>
                            <option value="3" {{if $search_status eq 3}}selected{{/if}}>已作废</option>
                        </select>
                        外发工厂：
                            <select class="selectCss2" name="factorys" id="factorys">
                                <option value="">请选择</option>
                                {{foreach from=$factorys item=res key=key}}
                                <option value="{{$res}}" {{if $factory eq {{$res}}}}selected{{/if}}> {{$res}} </option>
                                {{/foreach}}
                            </select></td>
                        </select>
                        <select name="search_date" id="search_date"  class="selection select2_group" style="width:150px;" >
                            <option value="" >查询条件</option>
                            <option value="1" {{if $search_date eq 1}}selected{{/if}}>创建时间</option>
                            <option value="2" {{if $search_date eq 2}}selected{{/if}}>完成时间</option>
                        </select>
                        <input type="text"  name="starttime" value="{{$starttime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" /> - <input type="text"  name="endtime" value="{{$endtime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" />
                        &nbsp;
                        <input type="hidden" id="flag_excel" name = "flag_excel" value="0">
                        <button class="btn btn_orange btn_search radius50" >查询</button>
                        <button type = "button" class="btn btn_orange btn_search radius50" onclick="addPrint()">打印订单</button>
                        <button type = "button" class="btn btn_orange btn_search radius50" onclick="updOrderStatus(2);">标完成</button>
                        <button type = "button" class="btn btn_orange btn_search radius50" onclick="updOrderStatus(3);">标作废</button>
                        <button type = "button" class="btn btn_orange btn_search radius50" onclick="outExcel()">数据下载</button>
                    </div>
                </form>
                <!--搜索栏结束-->
                <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
                    <thead>
                    <tr class="lbbt">
                        <td bgcolor="#FEFFF1">
                            <a onClick="allSelect('ppid[]')">全选<input type="checkbox"></a>
                        </td>
                        <td  bgcolor="#FEFFF1">序号</td>
                        <td  bgcolor="#FEFFF1">商品编号</td>
                        <td  bgcolor="#FEFFF1" width="6%">图片</td>
                        <td  bgcolor="#FEFFF1">状态<br/>工厂</td>
                        <td  bgcolor="#FEFFF1">印花数<br/>印花价格<br/>印花总价格</td>
                        <td  bgcolor="#FEFFF1">绣花数<br/>绣花价格<br/>绣花总价格</td>
                        <!--
                        <td  bgcolor="#FEFFF1">主料价格</td>
                        <td  bgcolor="#FEFFF1">辅料价格</td>
                        -->
                        <td  bgcolor="#FEFFF1">完成工期</td>
                        <td  bgcolor="#FEFFF1" width="16%">创建人<br/>创建时间<br/>完成时间</td>
                        <td  bgcolor="#FEFFF1" width="10%">操作</td>
                    </tr>
                    </thead>
                    <tbody >

                    {{foreach from=$orderlist item=li key=key}}
                    <tr>
                        <td valign="middle" bgcolor="#FFFFFF">
                            <input name="ppid[]" type="checkbox" class="none" id="ppid[]" value="{{$li.id}}"/>
                            {{if $li.print_flag eq 1}}<img src="/fuman/images/print.png">{{/if}}
                        </td>
                        <td valign="middle" bgcolor="#FFFFFF" style="position:relative;">
                            <a href="/productprint/editproductprint?id={{$li.id}}">
                                <font color="#6666FF">{{$li.id}}</font>
                            </a>

                        </td>
                        <td valign="middle" bgcolor="#FFFFFF">
                            <a href="/product/productlist?other={{$li.goods_code}}" >{{$li.goods_code}}</a>
                        </td>
                        <td valign="middle" bgcolor="#FFFFFF">
                            {{if $li.img_thumb_url}}
                                <img src="http://192.168.1.66/{{$li.img_thumb_url}}">
                            {{else}}
                                <!--
                                <img src="http://{{$smarty.server.SERVER_NAME}}/fuman/images/s-l500.jpg">
                                -->
                                <a href="http://192.168.1.66/{{$li.local_url}}" target="_blank">
                                    <img src="http://192.168.1.66/{{$li.thumb_url}}">
                                </a>
                            {{/if}}

                        </td>
                        <td valign="middle" bgcolor="#FFFFFF">
                            {{if $li.status eq 1}}
                                生产中
                            {{elseif $li.status eq 2}}
                                已完成
                            {{else}}
                                已作废
                            {{/if}}
                            <br>{{$li.factory}}
                        </td>
                        <td height="58" bgcolor="#FFFFFF" style="position:relative;">
                            {{$li.print_stock}}<br>{{$li.print_price}}<br>{{$li.print_price*$li.print_stock}}
                        </td>
                        <td bgcolor="#FFFFFF" class="cz">{{$li.embroider_stock}}<br>{{$li.embroider_price}}<br>{{$li.embroider_price*$li.embroider_stock}}</td>
                        <!--
                        <td  bgcolor="#FEFFF1">{{$li.master_price}}</td>
                        <td  bgcolor="#FEFFF1">{{$li.lesser_price}}</td>
                        -->
                        <td bgcolor="#FFFFFF" class="cz">{{$li.projecttime}}&nbsp;天</td>
                        <td bgcolor="#FFFFFF" class="cz">
                            {{$li.create_user}}<br/>
                            {{$li.createtime}}<br/>
                            {{$li.finishtime}}
                        </td>
                        <td bgcolor="#FFFFFF" class="cz">
                            <span id="showstatus">
                                {{if $li.status eq 3}}
                                    已作废
                                {{elseif $li.status eq 2}}
                                    已完成
                                {{else}}
                                    <a href="javascript:void(0);" onclick="updfactorystatus({{$li.id}},2)" style="color:#056dae;">
                                        完成
                                    </a>
                                    &nbsp;&nbsp;&nbsp;
                                    <a href="javascript:void(0);" onclick="updfactorystatus({{$li.id}},3)" style="color:#056dae;">
                                        作废
                                    </a>
                                {{/if}}
                            </span>
                        </td>

                    </tr>
                    {{/foreach}}
                    </tbody>
                </table>
                <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
            </div>
        </div>

</body>
</html>